#ifndef MYVIEW_H
#define MYVIEW_H

#include <QGraphicsView>

extern const int radius;

class QTcpSocket;

class MyView : public QGraphicsView
{
    Q_OBJECT
    Q_ENUMS(Mode)
	Q_ENUMS(LockState)

public:
    explicit MyView(QWidget *parent = 0);
    
	enum Mode { BrushMode, RubberyMode };
	enum LockState { NoLock, MyLock, OtherLock };

	LockState lockState();

signals:
	void painted(int mode, QPoint point);
	void sceneState(QTcpSocket *socket, QList<QPair<int, QPoint> > list);

public slots:
	void setMode(int mode);
	void setLockState(LockState lock);
	void paint(int mode, QPoint point, bool noEmit);
	void onSceneStateNeeded(QTcpSocket *s);

protected:
    void enterEvent(QEvent *event);
    void leaveEvent(QEvent *event);
    void mousePressEvent(QMouseEvent *event);
	void mouseMoveEvent(QMouseEvent *event);

private:
	void paint(QPoint point, bool noEmit = false);
private:
    Mode m_mode;
	LockState m_lock;
};

#endif // MYVIEW_H
